package com.celebracion.user;

import com.celebracion.NombresActivity;
import com.celebracion.R;
import com.celebracion.R.id;
import com.celebracion.R.layout;
import com.celebracion.R.string;
import com.celebracion.util.DBUtil;
import com.celebracion.util.FileUtil;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class MenuDialogActivity extends Activity {

	
	Button btnFinalizarEvento;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_menu_dialog);
		btnFinalizarEvento=(Button)findViewById(R.id.btMenuFinalizarEvento);
	}
	
	
	@Override
	protected void onStart() {
		super.onStart();
		if(DBUtil.getInstance(getBaseContext()).getEventoActivo()==null){
			btnFinalizarEvento.setVisibility(View.GONE);
			btnFinalizarEvento.setClickable(false);
		}
	}
	
	public void verEventosPendientes(View view){
		startActivity(new Intent(this,VisorEventosPrevistosActivity.class));
	}
	
	public void crearEvento(View view){
		startActivity(new Intent(this,CrearEventoActivity.class));
	}
	
	public void finalizarEvento(View view){
		AlertDialog.Builder builder = new AlertDialog.Builder(this);

		// 2. Chain together various setter methods to set the dialog characteristics
		builder.setMessage(R.string.askFinalizarEvento)
		       .setTitle(R.string.askTitleFinalizarEvento);
		// Add the buttons
		builder.setPositiveButton(R.string.Si, new DialogInterface.OnClickListener() {
		           public void onClick(DialogInterface dialog, int id) {
		        	   DBUtil.getInstance(MenuDialogActivity.this.getBaseContext()).finalizarEvento();
		        	   Intent intent=new Intent(MenuDialogActivity.this,NombresActivity.class);
		        	   //Vacia la pila de la tarea hasta esta 
		        	   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		       		   startActivity(intent);
		       		   
		       		
		       		   
		           }
		       });
		builder.setNegativeButton(R.string.No, new DialogInterface.OnClickListener() {
		           public void onClick(DialogInterface dialog, int id) {
		        	  
		           }
		       });
		// 3. Get the AlertDialog from create()
		AlertDialog dialog = builder.create();
		dialog.show();
	}
	
	public void atras(View v){
		finish();
	}
	
	public void cambiarPass(View view){
	   Intent intent=new Intent(this,ChangePassActivity.class);
	   //Vacia la pila de la tarea hasta esta 
	   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	   startActivity(intent);
	}

	

}
